var e = require;
var t = module;
var o = exports;
var n,
    i = o,
    a =
        ((n = function (e, t) {
            return (n =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (e, t) {
                        e.__proto__ = t;
                    }) ||
                function (e, t) {
                    for (var o in t) t.hasOwnProperty(o) && (e[o] = t[o]);
                })(e, t);
        }),
        function (e, t) {
            function o() {
                this.constructor = e;
            }
            n(e, t), (e.prototype = null === t ? Object.create(t) : ((o.prototype = t.prototype), new o()));
        }),
    r = function (e, t, o, n) {
        var i,
            a = arguments.length,
            r = a < 3 ? t : null === n ? (n = Object.getOwnPropertyDescriptor(t, o)) : n;
        if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(e, t, o, n);
        else
            for (var s = e.length - 1; s >= 0; s--)
                (i = e[s]) && (r = (a < 3 ? i(r) : a > 3 ? i(t, o, r) : i(t, o)) || r);
        return a > 3 && r && Object.defineProperty(t, o, r), r;
    };
Object.defineProperty(i, "__esModule", {value: !0});
var s = e("BehaviorTree"),
    c = e("BevNodeTerminal"),
    l = e("GameData"),
    d = e("GameModuleView"),
    u = cc._decorator,
    p = u.ccclass,
    h =
        (u.property,
        (function (e) {
            function t() {
                var t = (null !== e && e.apply(this, arguments)) || this;
                return (
                    (t.snake = null),
                    (t.vector = null),
                    (t.target_pos = null),
                    (t.index = 0),
                    (t.isAttack = !0),
                    (t.dt = 0),
                    t
                );
            }
            return (
                a(t, e),
                (t.prototype._DoEvaluate = function (e) {
                    if (((this.snake = e.snake), !this.isAttack))
                        return (this.dt += e._dt), this.dt > 0.5 && (this.isAttack = !0), !1;
                    for (var t = d.default.Insance._layer_snake.snakeList, o = 0; o < t.length; o++) {
                        var n = t[o];
                        if (
                            !n.isDie &&
                            n.node.active &&
                            n &&
                            n.head_pos &&
                            n.snakeName != this.snake.snakeName &&
                            n.head_pos.sub(this.snake.head_pos).mag() < 300
                        ) {
                            var i = n.head_pos.x + 300 * n.snake_vector.x,
                                a = n.head_pos.y + 300 * n.snake_vector.y;
                            if (
                                ((this.target_pos = cc.v3(i, a, 0)),
                                this.target_pos.sub(cc.v3(0, 0, 0)).mag() > l.default.instance.MapSize / 2 - 20 - 100)
                            )
                                continue;
                            if (this.target_pos.sub(n.head_pos).mag() < this.target_pos.sub(this.snake.head_pos).mag())
                                continue;
                            var r = this.target_pos.sub(this.snake.head_pos).normalize(),
                                s = cc.v2(r.x, r.y);
                            return (this.vector = s), !0;
                        }
                    }
                    return !1;
                }),
                (t.prototype._DoEnter = function () {
                    (this.index = 0), (this.dt = 0);
                }),
                (t.prototype._DoExecute = function (e, t) {
                    return (
                        (t.vector = this.snake.snake_vector),
                        (t.speed = !0),
                        this.index++,
                        this.index > 20 && (this.isAttack = !1),
                        this.target_pos.sub(this.snake.head_pos).mag() < 5
                            ? s.BevRunningStatus.k_BRS_Finish
                            : s.BevRunningStatus.k_BRS_Executing
                    );
                }),
                (t.prototype._DoExit = function () {
                    (this.index = 0), (this.dt = 0);
                }),
                r([p], t)
            );
        })(c.BevNodeTerminal));
i.default = h;
